<?php
if(!session_id()) { @session_start(); }

  $root = dirname(dirname(dirname(dirname(dirname(dirname(__FILE__)))))); 

if (file_exists($root.'/wp-load.php')) {
      
  require_once($root.'/wp-load.php'); 

}   
error_reporting(0);
$plugin_url = plugins_url('',  dirname(__FILE__));
$base =   dirname(dirname(dirname(__FILE__)));

if(get_option('moveto_thankyou_page') == ''){
	$thankyou_page_url = get_option('siteurl').'/wp-content/plugins/moveto/frontend/mp_thankyou.php';
}else{
	$thankyou_page_url = get_option('moveto_thankyou_page');
}

$trans_id = file_get_contents("transaction_id.txt", true);
unlink("transaction_id.txt") or die("Couldn't delete file");
echo "Please Wait...";
?>
<script src="../js/jquery-2.1.4.min.js" type="text/javascript"></script>
<script>
var dataString = <?php   echo $_SESSION['payfast_post_session']; ?>;
function ct_checkout_at_booking_complete(trans_id){
	dataString['payment_method'] = "payfast_payment";
	dataString['payfast_transaction_id'] = trans_id;

	jQuery.ajax({
		type:'POST',
		url:'mp_front_ajax.php',
		data: dataString,
		success:function(response){
			if(jQuery.trim(response) == "Booking done"){
				window.location.href='<?php echo $thankyou_page_url;?>';
			}
		}
	});
}
ct_checkout_at_booking_complete('<?php echo $trans_id; ?>');
</script>